package twentyone.proxy.homework;

import javax.swing.*;
import java.awt.*;
import java.awt.image.ImageObserver;
import java.net.URL;

public class ImageIconProxy implements Icon {
    public static int count = 0;
    ImageIcon real;
    int width = -1;
    int height = -1;
    public ImageIconProxy() {

    }

    @Override
    public void paintIcon(Component c, Graphics g, int x, int y) {
        if(real == null){
            realize();
        }
        count++;
        real.paintIcon(c,g,x,y);
    }
    public static int getCount(){
        return count;
    }
    @Override
    public int getIconWidth() {
        return width;
    }

    @Override
    public int getIconHeight() {
        return height;
    }
    public void realize(){
        if(real == null){
            real = new ImageIcon();
        }
    }
}
